#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
    long long n = 0;
    scanf("%d", &n);
    int a = 1;
    int count = 0;
    if (n < 0)
    {
        count++;
        n = n * -1;
    }
    while (a != 0)
    {
        a = (n + 1) / 2;
        n = n >> 1;
        count += a - n;
    }
    printf("%d", count);
    return 0;
}